package Test.Product;

import java.util.*;

public class ProductTest01 {
    public static void main(String[] args) {
        List<Product> list = new ArrayList<>();
        Product p1 = new Product("宝洁","洗手粉",18.5);
        Product p2 = new Product("联合利华","肥皂",4.5);
        Product p3 = new Product("宝洁","牙膏",32.5);
        Product p4 = new Product("宝洁","毛巾",14.5);
        Product p5 = new Product("洁利","洗面奶",26.0);
        Product p6 = new Product("好迪","洗发水",27.5);
        Product p7 = new Product("多芬","沐浴露",38.5);
        Product p8 = new Product("宝洁","洗洁精",3.4);

        list.add(p1);
        list.add(p2);
        list.add(p3);
        list.add(p4);
        list.add(p5);
        list.add(p6);
        list.add(p7);
        list.add(p8);

        //  method02(list);
        test05(list);
    }

    private static void test05(List<Product> list) {
        Map<String,List<Product>> map=new HashMap<>();
        for (Product p:list
             ) {
            String brand=p.getBrand();
            if (map.containsKey(brand)){
        List<Product> list1=map.get(brand);
        list1.add(p);
        map.put(brand,list1);
            }else {
                List<Product> productList =new ArrayList<>();
                map.put(brand,productList);
            }

        }
         Set<String >keyset=map.keySet();
        Map<String,Double> map1=new HashMap<>();
        Iterator<String> iterator=keyset.iterator();
        while(iterator.hasNext()){
       //     String,Double
        }
    }
}
